<!--
 @description 订单详情-备注信息
 @fileName CommentInfo.vue
 @author zengqiongying
 @created 2021/07/10 13:36:28
-->
<template>
  <div>
    <div class="mb10">
      <div class="qup-title-box"><span class="border" /><span>买家备注</span></div>
      <table-box
        ref="refBuyerTable"
        :table-max-height="400"
        show-index
        :data="buyerCommentData"
        :table-config="buyerTableConfig"
        :other-filters="buyerOtherFilters"
        :table-sortable="false"
      />
    </div>
    <div class="mb10">
      <div class="qup-title-box"><span class="border" /><span>卖家备注</span></div>
      <table-box
        ref="refSalerTable"
        :table-max-height="400"
        show-index
        :data="sellCommentData"
        :table-config="salerTableConfig"
        :other-filters="salerOtherFilters"
        :table-sortable="false"
      />
    </div>
    <div class="mb10">
      <div class="qup-title-box"><span class="border" /><span>订单备注</span></div>
      <table-box
        ref="refOrderTable"
        :table-max-height="400"
        show-index
        :table-sortable="false"
        :data="orderCommentData"
        :table-config="orderTableConfig"
        :other-filters="orderOtherFilters"
      />
    </div>
  </div>
</template>

<script>
import tabMixin from './mixin'
import { parseTime } from '@/utils'

export default {
  name: 'OrderCommentInfo',
  mixins: [tabMixin],
  data() {
    return {
      buyerCommentData: [],
      sellCommentData: [],
      orderCommentData: [],
      buyerOtherFilters: [],
      salerOtherFilters: [],
      orderOtherFilters: [],
      tableConfig: {
        // interfacePath: `${process.env.VUE_APP_BASE_API}/api/v1/orderCommentInfo/page`,
        interfacePath: '',
        hideSearchBar: true,
        hideFuncBar: true,
        pageSize: 50,
        // sort: 'soTime', // 开单时间
        // order: 'desc',
        setting: [
          {
            prop: 'commentTime',
            label: '时间',
            width: 150,
            formatData: ({ commentTime }) => {
              return parseTime(commentTime)
            }
          },
          {
            prop: 'commentBy',
            label: '备注人',
            width: 150
          },
          {
            prop: 'commentType',
            label: '备注类型',
            width: 150,
            type: 'select',
            propEnum: {
              domainCode: 'marketing',
              appCode: 'eco',
              dictTypeCode: 'COMMENT_TYPE'
            }
          },
          {
            prop: 'commentInfo',
            label: '备注信息',
            minWidth: 200,
            overflowHidden: false
          }
        ],
        btnList: []
      }
    }
  },
  computed: {

  },
  created() {
    this.buyerTableConfig = { ...this.tableConfig, ...{ tabIndex: 26 }}
    this.salerTableConfig = { ...this.tableConfig, ...{ tabIndex: 27 }}
    this.orderTableConfig = { ...this.tableConfig, ...{ tabIndex: 28 }}
    // this.setOtherFilter()
  },
  methods: {
    initData() {
      /*  this.setOtherFilter()
      this.$nextTick(() => {
        this.$refs.refTable && this.$refs.refTable.initTableData()
      }) */
      this.buyerCommentData = (this.orderData && this.orderData.buyerReMarkList) || []
      this.sellCommentData = (this.orderData && this.orderData.sellRemarkList) || []
      this.orderCommentData = (this.orderData && this.orderData.orderRemarkList) || []
    },
    setOtherFilter() {
      // dcCode 查询
      this.buyerOtherFilters = [
        { id: 'orderId', property: 'orderId', operator: '=', value: this.orderId },
        { id: 'commentCategory', property: 'commentCategory', operator: '=', value: '01' }
      ]
      this.salerOtherFilters = [
        { id: 'orderId', property: 'orderId', operator: '=', value: this.orderId },
        { id: 'commentCategory', property: 'commentCategory', operator: '=', value: '02' }
      ]
      this.orderOtherFilters = [
        { id: 'orderId', property: 'orderId', operator: '=', value: this.orderId },
        { id: 'commentCategory', property: 'commentCategory', operator: '=', value: '03' }
      ]
    }
    // getCommentData() {
    //   this.buyerOtherFilters = []
    //   this.salerOtherFilters = []
    //   this.orderOtherFilters = []
    //   fetchOrderComment({ orderId: this.orderId, dcCode: this.orderData.dcCode }).then(res => {
    //     if (res.data && res.data.length) {
    //       this.buyerCommentData = res.data.filters(v => v.commentCategory === '01')
    //       this.sellCommentData = res.data.filters(v => v.commentCategory === '02')
    //       this.orderCommentData = res.data.filters(v => v.commentCategory === '03')
    //     }
    //   })
    // }
  }
}

</script>
<style lang='scss' scoped>
.mb10{
  margin-bottom: 10px;
}
</style>
